cmake_minimum_required(VERSION 3.10)

# 项目名称
project(MyProject)

set(CMAKE_TOOLCHAIN_FILE "C:/Code/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)



# 收集所有源文件
file(GLOB SOURCES "src/*.cpp")
file(GLOB HEADERS "src/*.h")
# file(GLOB LIB "lib/*.lib")
# 添加库目标
add_executable(USE_IMAGEWRAP  ${SOURCES} ${HEADERS}) 
# 包含头文件目录
target_include_directories( USE_IMAGEWRAP PRIVATE  ${CMAKE_CURRENT_SOURCE_DIR}/../src)
# 设置输出目录
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug)
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug)

set_target_properties(USE_IMAGEWRAP PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../bin
)

# 设置目标的导出目录
# set_target_properties(USE_IMAGEWRAP PROPERTIES
#     LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin"
#     ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin"
#     RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin"
# )

message(STATUS "Library Output Directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")




target_link_libraries(USE_IMAGEWRAP PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug/IMAGEWRAP.lib)
target_compile_definitions(USE_IMAGEWRAP PRIVATE IMAGEWRAP_EXPORTS)

set(CMAKE_PREFIX_PATH "C:\\Code\\vcpkg\\packages\\mozjpeg_x64-windows;C:\\Code\\vcpkg\\packages\\openjpeg_x64-windows")

find_package(mozjpeg CONFIG REQUIRED)
target_link_libraries(USE_IMAGEWRAP PRIVATE mozjpeg::jpeg mozjpeg::turbojpeg)

find_package(OpenJPEG CONFIG REQUIRED)
target_link_libraries(USE_IMAGEWRAP PRIVATE openjp2)



# 定义源文件和目标目录
set(SOURCE_FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/../lib/jpeg62.dll
    ${CMAKE_CURRENT_SOURCE_DIR}/../lib/openjp2.dll
    ${CMAKE_CURRENT_SOURCE_DIR}/../lib/turbojpeg.dll
)
set(DESTINATION_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug)

# 在配置阶段复制文件
file(COPY ${SOURCE_FILES} DESTINATION ${DESTINATION_DIR})